
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: resolve => require(['@/views/login/Login.vue'], resolve),
    meta: {
      title: '登录',
      login_state: false,
    },
  },
  {
    path: '/home',
    name: 'home',
    component: resolve => require(['@/views/home/Home.vue'], resolve),
    meta: {
      title: '主页',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/teacherhome',
    name: 'teacherhome',
    component: resolve => require(['@/views/home/TeacherHome.vue'], resolve),
    meta: {
      title: '班级学生就业情况',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/classstatus',
    name: 'classstatus',
    component: resolve => require(['@/views/module/teacher/ClassTable.vue'], resolve),
    meta: {
      title: '班级学生就业信息',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/majorhome',
    name: 'majorhome',
    component: resolve => require(['@/views/home/TeacherMajorHome.vue'], resolve),
    meta: {
      title: '专业学生就业情况',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/majorstatus',
    name: 'majorstatus',
    component: resolve => require(['@/views/module/teacher/MajorTable.vue'], resolve),
    meta: {
      title: '专业学生就业信息',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/student',
    name: 'student',
    component: resolve => require(['@/views/home/Student.vue'], resolve),
    meta: {
      title: '学生主页',
      login_state: true,
    },
  },
  {
    path: '/collect',
    name: 'collect',
    component: resolve => require(['@/views/module/Collect.vue'], resolve),
    meta: {
      title: '我的收藏',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/enterinfo',
    name: 'enterinfo',
    component: resolve => require(['@/components/module/student/EnterInfo.vue'], resolve),
    meta: {
      title: '岗位信息',
    },
  },
  {
    path: '/resume',
    name: 'resume',
    component: resolve => require(['@/views/module/Table.vue'], resolve),
    meta: {
      title: '简历投递情况',
      login_state: true,
      inside: true,
    },
  },
  {
    path: '/employment',
    name: 'employment',
    component: resolve => require(['@/views/module/student/EmployMent'], resolve),
    meta: {
      title: '就业信息',
      login_state: true,
      inside: true,
    },
  },

  {
    path: '/enterhome',
    name: 'enterhome',
    component: resolve => require(['@/views/home/EnterHome.vue'], resolve),
    meta: {
      title: '岗位管理',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/resumeaccept',
    name: 'resumeaccept',
    component: resolve => require(['@/views/module/enter/ResumeTable.vue'], resolve),
    meta: {
      title: '简历受理',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/resumeinfo',
    name: 'resumeinfo',
    component: resolve => require(['@/components/module/enter/ResumeInfo.vue'], resolve),
    meta: {
      title: '投递人信息',
      login_state: true,
    },
  },
  {
    path: '/enterworkinfo',
    name: 'enterworkinfo',
    component: resolve => require(['@/components/module/enter/EnterWorkInfo.vue'], resolve),
    meta: {
      title: '岗位信息',
      login_state: true,
    },
  },
  {
    path: '/getenter',
    name: 'getenter',
    component: resolve => require(['@/components/module/enter/MyselfInfo.vue'], resolve),
    meta: {
      title: '公司信息',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/setting/user',
    name: 'setting_user',
    component: resolve => require(['@/views/setting/UserSetting.vue'], resolve),
    meta: {
      title: '个人信息',
      login_state: true,
      inside: true,
    },
  },
  {
    path: '/setting/password',
    name: 'setting_password',
    component: resolve => require(['@/views/setting/PasswordSetting.vue'], resolve),
    meta: {
      title: '密码修改',
      login_state: true,
      inside: true,
    },
  },
  {
    path: '/setting/headimg',
    name: 'setting_headimg',
    component: resolve => require(['@/views/setting/HeadSetting.vue'], resolve),
    meta: {
      title: '头像修改',
      login_state: true,
      inside: true,
    },
  },

  {
    path: '/page/message/list',
    name: 'message_list',
    component: resolve => require(['@/views/page/MessageList.vue'], resolve),
    meta: {
      title: '留言',
      inside: true,
      login_state: true,
    },
  },

  {
    path: '/',
    name: 'login',
    component: resolve => require(['@/views/login/Login.vue'], resolve),
    meta: {
      title: '登录',
      inside: false,
    },
  },
  {
    path: '/register',
    name: 'register',
    component: resolve => require(['@/views/login/Register.vue'], resolve),
    meta: {
      title: '注册',
      inside: false,
    },
  },
  {
    path: '/forget/password',
    name: 'forget_password',
    component: resolve => require(['@/views/login/ForgetPassword.vue'], resolve),
    meta: {
      title: '找回密码',
      inside: false,
    },
  },
  {
    path: '/page/not/found',
    name: 'not_found',
    component: resolve => require(['@/views/page/NotFound.vue'], resolve),
    meta: {
      title: '页面不存在',
      inside: false,
      login_state: false,
    },
  },
  {
    path: '/page/warning',
    name: 'warning',
    component: resolve => require(['@/views/page/Warning.vue'], resolve),
    meta: {
      title: '系统错误',
      inside: false,
      login_state: false,
    },
  },

  {
    path: '/setting/user',
    name: 'setting_user',
    component: resolve => require(['@/views/setting/UserSetting.vue'], resolve),
    meta: {
      title: '个人设置',
      inside: true,
      login_state: true,
    },
  },
  {
    path: '/setting/password',
    name: 'setting_password',
    component: resolve => require(['@/views/setting/PasswordSetting.vue'], resolve),
    meta: {
      title: '密码修改',
      inside: true,
      login_state: true,
    },
  },

]

const router = new VueRouter({
  routes
})
router.beforeEach((to, from, next) => {
  if (to.meta.login_state) {
    document.title = to.meta.title
    next()
  } else {
    document.title = to.meta.title
    next()
  }
})

export default router